package Figures;

import java.awt.*;
import java.io.Serializable;

/**
 * 类功能描述：
 *三角形类，其子类有直角三角形和等腰三角形，实现了draw，fill等方法，利用2DAPI实现的绘制和填充三角形功能
 * @author lix
 * @date 2024/01/02
 */

public class Triangle extends ClosedGraphics implements Serializable {

    protected Point point1;
    protected Point point2;
    protected Point point3;

    protected int[] triangle_x;//三个顶点x坐标
    protected int[] triangle_y;//三个顶点y坐标
    protected Polygon triangle;//三角形对象

    public Triangle(Point start, Point end, int size, Color color) {
        super(start, end, size, color);
        triangle = new Polygon();
    }

    @Override
    public void fill(Graphics2D g) {
        g.setColor(getFillColor());
        g.fill(triangle);
    }

    @Override
    public void Draw(Graphics2D g) {
        g.setColor(ShapeColor);
        g.setStroke(new BasicStroke(size));
        g.draw(triangle);
        if (fillColor != null) {
            g.setColor(fillColor);
            g.fill(triangle);
        }
        if (isSelected) showSelectBorder(g);
    }



}
